package cn.hp.customer.service.impl;

import cn.hp.customer.service.CustomerPhoneService;
import cn.hp.customer.util.ResponseData;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class CustomerPhoneServiceImpl implements CustomerPhoneService {

    @Override
    public ResponseData calculatedAmount(String dis) {
        // 根据距离计算金额
        double distance = Double.parseDouble(dis);
        if (distance < 1000){
            return ResponseData.success(10);
        }else {
            double newDistance= distance -1000 ;
//            附加价格 新距离%1000 价格倍数 *3 + 10
            int money = (newDistance%1000==0?(int)(newDistance/1000):(int)(newDistance/1000)+1)*3 + 10;
            return ResponseData.success(money);
        }
    }
}
